﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace ConsolidationTool.Common
{
    public interface IEncryptionCompressed
    {
        string Encryption();
    }

    [Serializable]
    public class ARTTableRow
    {
        public ARTTableRow()
        {
            fields = new List<ARTTableColumn>();
        }
        public List<ARTTableColumn> fields { get; set; }
    }
    [Serializable]
    public class ARTTableColumn
    {
        public string title { get; set; }
        public int colspan { get; set; }
    }

    [Serializable]
    public class TemplateItem
    {
        public string title { get; set; }
        public string list { get; set; }
        public List<TemplateItemField> fields { get; set; }


        public bool titleRow { get; set; }
        public int fieldCount { get; set; }
        public bool emptyRow { get; set; }
        public bool M12 { get; set; }
        public bool Budget { get; set; }
        public bool avg { get; set; }
        public bool withCurrentMonth { get; set; }

        public string equType { get; set; }
        public string[] equFields { get; set; }
        public string equ { get; set; }
        public string type { get; set; }
        /// <summary>
        /// 获取每个字段的历史12月的和
        /// </summary>
        public bool C12 { get; set; }
        public bool compress { get; set; }

        public string otherExp { get; set; }
        public bool onlycm { get; set; }
    }
    [Serializable]
    public class TemplateItemField
    {
        public bool emptycolumn { get; set; }
        public bool self { get; set; }
        public bool komode { get; set; }
        public string name { get; set; }
        public string[] fields { get; set; }
        public string method { get; set; }
        public string type { get; set; }
        public string value { get; set; }
        public string addition { get; set; }
        public string list { get; set; }

        public bool budget { get; set; }
    }
    [Serializable]
    public class SearchEntity : ICloneable, IEncryptionCompressed
    {
        public SearchEntity()
        {
            Budget = true;
        }
        public string List { get; set; }
        public string Entity { get; set; }
        public string CompanyName { get; set; }
        public string Toannge { get; set; }
        public string[] fields { get; set; }
        public string equ { get; set; }
        public string Currency { get; set; }
        /// <summary>
        /// 修改一下从SelectedDateTime中取值。。。。
        /// </summary>
        public int Year { get; set; }
        /// <summary>
        /// 修改一下从SelectedDateTime中取值。。。。
        /// </summary>
        public int Month { get; set; }
        public string EngMonth { get; set; }
        public string LocalCurrency
        {
            get
            {
                return Currency.StartsWith("K") ? Currency.Substring(1) : Currency;
            }
        }

        public string CM { get { return EngMonth + " " + Year; } }
        public string YTDM { get { return "YTD " + EngMonth + " " + Year; } }

        public DateTime SelectedDateTime { get; set; }

        public void UpdateDate(int month)
        {
            this.Month = month;
            DateTime selectData = DateTime.Now;
            if (DateTime.TryParse(string.Format("{0}-{1}-{2}", this.Year, this.Month, 1), out selectData))
                this.SelectedDateTime = selectData;
        }

        public string ReportTitle { get { return string.Format("{0}{1}{2}{3}.xlsx", Year, Month, ReportTemplateName, Entity); } }

        public string ReportUrl { get { return SPContext.Current.Site.Url + "/" + Constants._EXCEL_Library + "/" + ReportTitle; } }

        public string ReportTemplateName { get; set; }

        public bool YTD { get; set; }

        public bool Budget { get; set; }

        public string GAPRow { get; set; }

        public string TableRow { get; set; }

        public string FreeRow { get; set; }

        public object Clone()
        {
            return this.MemberwiseClone();
        }

        public string Encryption()
        {
            return Entity + Year + Month;
        }

        public string EntityName { get; set; }
    }

    [Serializable]
    public class RQDataItem : ICloneable
    {
        public RQDataItem()
        {
            this.values = new List<string>();
        }
        public string title { get; set; }
        public List<string> values { get; set; }
        public string M_N_1 { get; set; }
        public string M_Actual { get; set; }
        public string M_Budget { get; set; }
        public string M_A_BUD { get; set; }
        public string M_A_N_1 { get; set; }

        public string YTD_N_1 { get; set; }
        public string YTD_Actual { get; set; }
        public string YTD_Budget { get; set; }
        public string YTD_A_BUD { get; set; }
        public string YTD_A_N_1 { get; set; }

        public string Max { get; set; }


        public bool emptyRow { get; set; }

        public string head { get; set; }
        public bool skip { get; set; }

        public string identity { get; set; }

        public string unit { get; set; }

        public string acountcode { get; set; }

        public bool subrow { get; set; }

        public object Clone()
        {
            return this.MemberwiseClone();
        }

        public string rcol { get; set; }
    }


    [Serializable]
    public class koOutputEntity : BaseKoOutputEntity
    {
        public decimal GetBudgetYTDValue(ARTReportFromItem from)
        {
            var value = 0.00M;
            for (int i = 1; i <= from.month; i++)
            {
                value += BusinessService.decimalParse(this.TryGetValue(from.profix + BusinessService.GetEngMonth(i) + from.suffix) + "");
            }
            return value;
        }
        public List<koSubRowOutputEntity> subrow { set; get; }
    }

    [Serializable]
    public class koSubRowOutputEntity : BaseKoOutputEntity
    {
    }

    [Serializable]
    public class BaseKoOutputEntity
    {
        //general
        public string accountcode { get; set; }
        public string description { get; set; }
        public int digits { get; set; }
        public string unit { get; set; }
        public string entity { get; set; }

        public bool emptyrow { get; set; }
        public bool controlrow { get; set; }
        public bool datarow { get; set; }
        public bool insertcontrol { get; set; }
        public bool bold { get; set; }
        public bool issubrow { get; set; }


        //budget
        public string L_Dec { get; set; }
        public string Jan { get; set; }
        public string Feb { get; set; }
        public string Mar { get; set; }
        public string Apr { get; set; }
        public string May { get; set; }
        public string Jun { get; set; }
        public string Jul { get; set; }
        public string Aug { get; set; }
        public string Sep { get; set; }
        public string Oct { get; set; }
        public string Nov { get; set; }
        public string Dec { get; set; }

        public string Jan_Qty { get; set; }
        public string Feb_Qty { get; set; }
        public string Mar_Qty { get; set; }
        public string Apr_Qty { get; set; }
        public string May_Qty { get; set; }
        public string Jun_Qty { get; set; }
        public string Jul_Qty { get; set; }
        public string Aug_Qty { get; set; }
        public string Sep_Qty { get; set; }
        public string Oct_Qty { get; set; }
        public string Nov_Qty { get; set; }
        public string Dec_Qty { get; set; }

        public string Jan_BA { get; set; }
        public string Feb_BA { get; set; }
        public string Mar_BA { get; set; }
        public string Apr_BA { get; set; }
        public string May_BA { get; set; }
        public string Jun_BA { get; set; }
        public string Jul_BA { get; set; }
        public string Aug_BA { get; set; }
        public string Sep_BA { get; set; }
        public string Oct_BA { get; set; }
        public string Nov_BA { get; set; }
        public string Dec_BA { get; set; }

        public string Jan_T { get; set; }
        public string Feb_T { get; set; }
        public string Mar_T { get; set; }
        public string Apr_T { get; set; }
        public string May_T { get; set; }
        public string Jun_T { get; set; }
        public string Jul_T { get; set; }
        public string Aug_T { get; set; }
        public string Sep_T { get; set; }
        public string Oct_T { get; set; }
        public string Nov_T { get; set; }
        public string Dec_T { get; set; }

        //in vm input
        public string Budget { get; set; }
        public string Actual { get; set; }
        public string Variance { get; set; }
        public string Vol { get; set; }
        public string Mix { get; set; }
        public string Price { get; set; }
        public string MP { get; set; }
        public string FPP { get; set; }
        public string PRO { get; set; }
        public string PT { get; set; }
        public string Others { get; set; }
        public string Control { get; set; }
        //actual simple input
        public string YTDM_1 { get; set; }
        public string CM { get; set; }
        public string YTD { get; set; }

        //actual arap input
        public string LM { get; set; }
        public string ND { get; set; }
        public string D15 { get; set; }
        public string D30 { get; set; }
        public string D60 { get; set; }
        public string D90 { get; set; }
        public string D150 { get; set; }
        public string G150 { get; set; }

        //forecast input
        public string M_1 { get; set; }
        public string M_2 { get; set; }
        public string M_3 { get; set; }
        public string FCST { get; set; }
        public string M_1_Qty { get; set; }
        public string M_1_BA { get; set; }
        public string M_1_T { get; set; }
        public string M_2_Qty { get; set; }
        public string M_2_BA { get; set; }
        public string M_2_T { get; set; }
        public string M_3_Qty { get; set; }
        public string M_3_BA { get; set; }
        public string M_3_T { get; set; }

        public string Budget_YTD { get; set; }
        public string Budget_CM { get; set; }
        
    }



    public class ListIns
    {
        public string ParentAccountCode { get; set; }
        public string AccountCode { get; set; }
        public string Description { get; set; }
        public string Unit { get; set; }
        public string Type { get; set; }
        public string Month1 { get; set; }
        public string Month2 { get; set; }
        public string Month3 { get; set; }
        public string Month4 { get; set; }
        public string Month5 { get; set; }
        public string Month6 { get; set; }
        public string Month7 { get; set; }
        public string Month8 { get; set; }
        public string Month9 { get; set; }
        public string Month10 { get; set; }
        public string Month11 { get; set; }
        public string Month12 { get; set; }


        public string Entity { get; set; }
        public string RGC { get; set; }
    }

    public class relaItem
    {
        public relaItem() { }
        public relaItem(string refstr, char split)
        {
            if (refstr.IndexOf(split) != -1)
            {
                ac = refstr.Split(split)[0];
                field = refstr.Split(split)[1];
            }
            else
                ac = refstr;
        }
        public string ac { get; set; }
        public string field { get; set; }
        public string type { get; set; }
        public string unit { get; set; }
        public string digits { get; set; }
        public string desc { get; set; }
        public bool hasSubrow { get; set; }
        public bool empty { get; set; }
        public bool bold { get; set; }
        public bool subrow { get; set; }
    }

    public class relaClass
    {
        public string Title { get; set; }
        public string[] Profix { get; set; }
        public List<relaItem> Fields { get; set; }
    }

    [Serializable]
    public class BaseKoEntity
    {
        public bool emptyrow { get; set; }
        public bool controlrow { get; set; }
        public bool datarow { get; set; }
        public bool insertcontrol { get; set; }
        public bool bold { get; set; }

        public string accountcode { get; set; }
        public string description { get; set; }
        public int digits { get; set; }
        public string unit { get; set; }

        //actual input
        public string YTDM_1 { get; set; }
        public string CM { get; set; }
        public string YTD { get; set; }

        //in vm input
        public string Budget { get; set; }
        public string Actual { get; set; }
        public string Variance { get; set; }
        public string Vol { get; set; }
        public string Mix { get; set; }
        public string Price { get; set; }
        public string MP { get; set; }
        public string FPP { get; set; }
        public string PRO { get; set; }
        public string PT { get; set; }
        public string Others { get; set; }
        public string Control { get; set; }

        //actual arap input
        public string LM { get; set; }
        public string ND { get; set; }
        public string D15 { get; set; }
        public string D30 { get; set; }
        public string D60 { get; set; }
        public string D90 { get; set; }
        public string D150 { get; set; }
        public string G150 { get; set; }


        //forecast input
        public string M_1 { get; set; }
        public string M_2 { get; set; }
        public string M_3 { get; set; }
        public string M_1_Qty { get; set; }
        public string M_1_T { get; set; }
        public string M_2_Qty { get; set; }
        public string M_2_T { get; set; }
        public string M_3_Qty { get; set; }
        public string M_3_T { get; set; }
        public string M_1_BA { get; set; }
        public string M_2_BA { get; set; }
        public string M_3_BA { get; set; }

        //budget
        public string L_Dec { get; set; }
        public string Jan { get; set; }
        public string Feb { get; set; }
        public string Mar { get; set; }
        public string Apr { get; set; }
        public string May { get; set; }
        public string Jun { get; set; }
        public string Jul { get; set; }
        public string Aug { get; set; }
        public string Sep { get; set; }
        public string Oct { get; set; }
        public string Nov { get; set; }
        public string Dec { get; set; }

        //psbr tsbr input
        public string Jan_Qty { get; set; }
        public string Feb_Qty { get; set; }
        public string Mar_Qty { get; set; }
        public string Apr_Qty { get; set; }
        public string May_Qty { get; set; }
        public string Jun_Qty { get; set; }
        public string Jul_Qty { get; set; }
        public string Aug_Qty { get; set; }
        public string Sep_Qty { get; set; }
        public string Oct_Qty { get; set; }
        public string Nov_Qty { get; set; }
        public string Dec_Qty { get; set; }

        public string Jan_T { get; set; }
        public string Feb_T { get; set; }
        public string Mar_T { get; set; }
        public string Apr_T { get; set; }
        public string May_T { get; set; }
        public string Jun_T { get; set; }
        public string Jul_T { get; set; }
        public string Aug_T { get; set; }
        public string Sep_T { get; set; }
        public string Oct_T { get; set; }
        public string Nov_T { get; set; }
        public string Dec_T { get; set; }

        //sid pid input
        public string Jan_IC { get; set; }
        public string Feb_IC { get; set; }
        public string Mar_IC { get; set; }
        public string Apr_IC { get; set; }
        public string May_IC { get; set; }
        public string Jun_IC { get; set; }
        public string Jul_IC { get; set; }
        public string Aug_IC { get; set; }
        public string Sep_IC { get; set; }
        public string Oct_IC { get; set; }
        public string Nov_IC { get; set; }
        public string Dec_IC { get; set; }

        public string Jan_IA { get; set; }
        public string Feb_IA { get; set; }
        public string Mar_IA { get; set; }
        public string Apr_IA { get; set; }
        public string May_IA { get; set; }
        public string Jun_IA { get; set; }
        public string Jul_IA { get; set; }
        public string Aug_IA { get; set; }
        public string Sep_IA { get; set; }
        public string Oct_IA { get; set; }
        public string Nov_IA { get; set; }
        public string Dec_IA { get; set; }

        public string Jan_BA { get; set; }
        public string Feb_BA { get; set; }
        public string Mar_BA { get; set; }
        public string Apr_BA { get; set; }
        public string May_BA { get; set; }
        public string Jun_BA { get; set; }
        public string Jul_BA { get; set; }
        public string Aug_BA { get; set; }
        public string Sep_BA { get; set; }
        public string Oct_BA { get; set; }
        public string Nov_BA { get; set; }
        public string Dec_BA { get; set; }
    }

    [Serializable]
    public class fsentity : BaseKoEntity
    {
        public List<fssubentity> subrow { set; get; }
    }
    [Serializable]
    public class fssubentity : BaseKoEntity
    {
        public string entity { get; set; }
        public string RGCDescription { get; set; }
    }

}
